package com.zhsh.generator.template.config;

import lombok.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Service模板生成的配置
 *
 * @author fengshuonan
 * @date 2017-05-07 22:12
 */
@Data
public class ServiceConfig {

    private ContextConfig contextConfig;

    private String servicePathTemplate;
    private String serviceImplPathTemplate;
    /**
     * 包名称
     */
    private String packageName;

    private List<String> serviceImports;
    private List<String> serviceImplImports;

    public void init() {
        ArrayList<String> imports = new ArrayList<>();
        imports.add("com.alibaba.fastjson.JSON");
        imports.add("com.jd.yao.common.client.base.vo.Res");
        imports.add("com.jd.yao.common.base.exception.BizException");
        imports.add("com.jd.yao.common.client.base.vo.ResPage");
        imports.add("lombok.extern.slf4j.Slf4j");
        imports.add("java.util.ArrayList");
        imports.add("java.util.Date");
        imports.add("java.util.List");
        imports.add("org.apache.commons.lang3.StringUtils");
        imports.add("org.springframework.beans.factory.annotation.Autowired");
        imports.add("org.springframework.stereotype.Service");
        imports.add(contextConfig.getPackagePath() + "service." + contextConfig.getBizEnBigName() + "Service");
        imports.add(contextConfig.getPackagePath() + "dao." + contextConfig.getBizEnBigName() + "Mapper");
        imports.add(contextConfig.getPackagePath() + "domain.entity." + contextConfig.getBizEnBigName());
        imports.add(contextConfig.getPackagePath() + "domain.entity." + contextConfig.getBizEnBigName()+"Example");
        imports.add(contextConfig.getPackagePath() + "domain.vo." + contextConfig.getBizEnBigName() + "VO");
        imports.add(contextConfig.getPackagePath() + "domain.param." + contextConfig.getBizEnBigName() + "Param");
        imports.add(contextConfig.getPackagePath() + "domain.query." + contextConfig.getBizEnBigName() + "Query");
        Collections.sort(imports);
        this.serviceImplImports = imports;
        this.packageName = contextConfig.getPackagePath() + "service";
        //this.servicePathTemplate = "\\src\\main\\java\\com\\stylefeng\\guns\\modular\\" + contextConfig.getModuleName() + "\\service\\I{}Service.java";
        this.servicePathTemplate = "\\" + contextConfig.getTemplateFilePrefixWithLine() + "\\" + contextConfig.getModuleName() + "\\service\\{}Service.java";
        this.serviceImplPathTemplate = "\\" + contextConfig.getTemplateFilePrefixWithLine() + "\\" + contextConfig.getModuleName() + "\\service\\impl\\{}ServiceImpl.java";
    }

}
